/*
 * Resizable2DInterface.cpp
 *
 *  Created on: Jul 6, 2009
 *      Author: kurt
 */

#include "Resizable2DInterface.h"
#include "DrawingCanvas.h"
#include <sstream>
using namespace std;
using namespace objdraw;
Resizable2DInterface::~Resizable2DInterface() 
{
	
}
Resizable2DInterface::Resizable2DInterface() 
{
	start = Location(0,0);
	end = Location(0,0);
	color = Color(0,0,0);
	hidden = false;
	canvas = NULL;
}
Resizable2DInterface::Resizable2DInterface(Resizable2DInterface const & r)
{
	start = r.start;
	end = r.end;
	color = r.color;
	hidden = r.hidden;
	canvas = r.canvas;
	if(canvas != NULL)
		canvas->getCanvasContent().addDrawable(this);
}
void Resizable2DInterface::setHeight(float height)
{
	if(start.y < end.y)
		end.y = start.y + height;
	else
		start.y = end.y + height;
}
void Resizable2DInterface::setWidth(float width)
{
	if(start.x < end.x)
		end.x = start.x + width;
	else
		start.x = end.x + width;
}
void Resizable2DInterface::setSize(float width, float height)
{
	setWidth(width);
	setHeight(height);
}
void Resizable2DInterface::setStart(Location point)
{
	start = point;
}
void Resizable2DInterface::setEnd(Location point)
{
	end = point;
}
string Resizable2DInterface::toString()
{
	stringstream rstr("Resizable2DInterface: ");
	rstr << "start: " << start.toString() << 
	"end: " << end.toString() << 
	"color: " << color.toString() <<
	"hidden: " << hidden;
	return rstr.str();
}
